import mockApi from "@/api/mockApi";

export default class roomApi {
  static rooms = [
    {id: 1, buildingId: 1, buildingName: '北区1栋', roomNumber: '301', floorNumber: 3, grossFloorArea: 60.7, netFloorArea: 54.3, createTime: '2024-01-01 12:12:12', modifyTime: '2024-02-02 13:13:13'},
    {id: 2, buildingId: 2, buildingName: '北区1栋', roomNumber: '402', floorNumber: 4, grossFloorArea: 61.6, netFloorArea: 55.4, createTime: '2024-02-02 12:12:12', modifyTime: '2024-03-03 13:13:13'},
    {id: 3, buildingId: 3, buildingName: '南区1栋', roomNumber: '503', floorNumber: 5, grossFloorArea: 62.5, netFloorArea: 56.5, createTime: '2024-03-03 12:12:12', modifyTime: '2024-04-04 13:13:13'},
    {id: 4, buildingId: 4, buildingName: '南区2栋', roomNumber: '604', floorNumber: 6, grossFloorArea: 63.4, netFloorArea: 57.6, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'},
    {id: 5, buildingId: 5, buildingName: '南区2栋', roomNumber: '504', floorNumber: 5, grossFloorArea: 62.5, netFloorArea: 55.5, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'},
    {id: 6, buildingId: 6, buildingName: '东区1栋', roomNumber: '404', floorNumber: 4, grossFloorArea: 61.6, netFloorArea: 56.4, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'},
    {id: 7, buildingId: 7, buildingName: '东区2栋', roomNumber: '304', floorNumber: 3, grossFloorArea: 63.7, netFloorArea: 54.3, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'}
  ]

  static async save (params) {
    console.log('roomApi save params', params)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (params) {
    console.log('roomApi find params', params)
    const response = await mockApi.queryPageSuccessfully(roomApi.rooms)
    return response.data
  }

  static async findById (id) {
    console.log('roomApi findById id', id)
    let target = {}
    for (let a of roomApi.rooms) {
      if (a.id === id) {
        target = a
      }
    }
    const response = await mockApi.queryByIdSuccessfully(target)
    return response.data
  }

  static async del (id) {
    console.log('roomApi del id', id)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }
}